package eu.vranckaert.calendar;

import android.app.Activity;
import eu.vranckaert.calendar.util.CalendarView;
import eu.vranckaert.calendar.util.WeekDay;
import eu.vranckaert.calendar.widget.MonthCellView;
import eu.vranckaert.calendar.widget.Workspace;

import java.util.Date;
import java.util.List;

/**
 * User: Dirk Vranckaert
 * Date: 18/02/13
 * Time: 14:26
 */
public class CalendarViewHelper {
    private CalendarView calendar;

    private CalendarViewHelper() {}

    public static CalendarViewHelper initCalendarDay(Activity context, Workspace workspace, Date initDate, int blockColorResId, CalendarDayView.OnDataLoadListener onDataLoadListener) {
        CalendarDayView dayView = CalendarDayView.initCalendar(context, workspace, initDate, blockColorResId, onDataLoadListener);

        CalendarViewHelper helper = new CalendarViewHelper();
        helper.calendar = dayView;
        return helper;
    }

    public static CalendarViewHelper initCalendarFixedDays(Activity context, Workspace workspace, Date initDate, int days, int blockColorResId, CalendarDayView.OnDataLoadListener onDataLoadListener) {
        CalendarDayView dayView = CalendarDayView.initCalendarFixedDays(context, workspace, initDate, days, blockColorResId, onDataLoadListener);

        CalendarViewHelper helper = new CalendarViewHelper();
        helper.calendar = dayView;
        return helper;
    }

    public static CalendarViewHelper initCalendarWeek(Activity context, Workspace workspace, Date initDate, WeekDay firstDayOfWeek, int weekBlockColorResId, List<Integer> blockColorResIds, CalendarDayView.OnDataLoadListener onDataLoadListener) {
        CalendarWeekView weekView = CalendarWeekView.initCalendar(context, workspace, initDate, weekBlockColorResId, blockColorResIds, firstDayOfWeek, onDataLoadListener);

        CalendarViewHelper helper = new CalendarViewHelper();
        helper.calendar = weekView;
        return helper;
    }

    public static CalendarViewHelper initCalendarMonth(Activity context, Workspace workspace, Date initDate, WeekDay firstDayOfWeek, CalendarDayView.OnDataLoadListener onDataLoadListener, MonthCellView.CellViewClickListener cellViewClickListener) {
        CalendarMonthView monthView= CalendarMonthView.initCalendar(context, workspace, initDate, firstDayOfWeek, onDataLoadListener, cellViewClickListener);

        CalendarViewHelper helper = new CalendarViewHelper();
        helper.calendar = monthView;
        return helper;
    }

    public void setOnTimeBlockClickListener(CalendarDayView.OnTimeBlockClickListener onTimeBlockClickListener) {
        calendar.setOnTimeBlockClickListener(onTimeBlockClickListener);
    }

    public void scrollAllScrollViewsTo(int scrollY) {
        calendar.scrollAllScrollViewsTo(scrollY);
    }

    public void reloadDataForDay(Date date) {
        calendar.reloadDataForDay(date);
    }

    public void reloadAllData() {
        calendar.reloadAllData();
    }

    public void setBlockColorResIds(List<Integer> blockColorResIds) {
        calendar.setBlockColorResIds(blockColorResIds);
    }

    public Date getCurrentDate() {
        return calendar.getCurrentDate();
    }
}
